#ifndef REL_H
#define REL_H

	// Libraries
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <pthread.h>
  #include <time.h>
  #include <sys/stat.h>
  #include <fcntl.h>

	// Include modules
  #include "network.h"
  #include "messages.h"
  #include "commandLine.h"
  #include "fileStatusMessage.h"
  #include "dataMessage.h"
  #include "ackMessage.h"
  #include "timer.h"
  #include "hostNetwork.h"
  #include "file.h"
  
  // Exit on error
  #define error(s) { perror(s); exit(1); }

  // Allow use of true and false
  enum BOOLEAN {false, true};

  /** CONSTANTS **/
  
  // Define max lengths for messages
  #define MSG_LEN 1400
  
  // Define max lengths for data
  #define DATA_LEN 1300

  // Define max length for file name
  #define FILENAME_LEN 22
  
  /** GLOBAL VARIABLES **/
  
  // Global buffer for messages received
  extern char receiveMessageBuffer [MSG_LEN];
  
  // Global buffer for messages to be sent
  extern char sendMessageBuffer [MSG_LEN];

  // Global buffer for file name
  extern char fileName [FILENAME_LEN];

  // Global int for file name length
  extern int fileNameLength;
  
  // Socket File Descriptor
  extern int socketfd;
  
  // Stores Port Number for receiver to bind on.  This
  // is the port number of the receiver
  extern unsigned short receiverPort;

  // Sender Information
  extern unsigned short senderPort;  
  extern char ipAddress[20];
  
  // Will be set if end of file has been reached
  extern char endOfFile;
  
  // Debugging BOOLEAN
  extern int debug;

  // Declare who is calling the function
  extern int sender;
  
  // Declare int for current sequence number
  extern unsigned long long currentSequenceNumber;
  
  // Timestamp of last response from other application
  extern time_t lastResponseTime;
  
  // Size of Message in Send Buffer
  extern int sendMessageSize;
  
  // Size of Message in Receive Buffer
  extern int receiveMessageSize;
    
  // Number of Retransmissions
  extern int numRetransmits;
  
  // Mutex
  extern pthread_mutex_t mutexLock;
  
  // Turn off timer
  extern int timerOn;
	
	// File Pointer Global
	extern FILE * fp;
	
	// Stopwatch Timer
	extern time_t start;
	
  // Boolean to test if transmission successful
  extern int successfulTransfer;
	
#endif